import Vue from 'vue'
import App from './App.vue'
//引入ElementUI
import ElementUI from 'element-ui'
import '@/assets/theme/index.css'
// 字体图标库
import "@/assets/iconfont/iconfont.css";
// markdown 样式
import '@/assets/style/markdown.scss'; 
// 文本复制插件
import VueClipboard from 'vue-clipboard2';
Vue.use(VueClipboard);
// 全局调整弹框
ElementUI.Dialog.props.closeOnClickModal.default = false

// 全局调整table
ElementUI.Table.props.tooltipEffect = { default: 'dark', type: String }
ElementUI.Table.props.border = { default: true, type: Boolean }
ElementUI.TableColumn.props.showOverflowTooltip = {
  default: true,
  type: Boolean
}

ElementUI.TableColumn.props.minWidth = { default: '130px', type: String }

// 全局调整select
ElementUI.Select.props.filterable = { default: true, type: Boolean }

// hacker fix 操作列右对齐
let c = ElementUI.TableColumn.mounted
ElementUI.TableColumn.mounted = function () {
  if (this.label === '操作' && !(this.fixed === 'right'))
    this.columnConfig.fixed = 'right'

  c.call(this)
}

// hacker fix 列表内tootip多行显示
let tb = ElementUI.Table.components.TableBody
let old = tb.methods.handleCellMouseEnter
tb.methods.handleCellMouseEnter = function (event, row) {
  old.call(this, event, row)
  let cell = event.target.querySelector('.cell')

  if (cell.childElementCount === 0) {
    this.tooltipContent = cell.textContent
  }
}
import { debounce } from 'lodash'
// 解决多选框抖动问题，大概
let o = ElementUI.Cascader.methods.updateStyle
let n = debounce(o, 30, { leading: true })
ElementUI.Cascader.methods.updateStyle = function () {
  n.call(this)
}

//引入路由
import router from './router'
//引入状态管理设置
import store from './store'

//兼容ie浏览器编译es6语法
import 'babel-polyfill'

//关闭生产环境下给出的提示
Vue.config.productionTip = false

//安装ui插件
Vue.use(ElementUI, { zIndex: 2100 })

// 安装权限插件
import VPermission from './plugins/permission'
Vue.use(VPermission)

// 暂无数据组件
import Empty from './publicComponents/Empty'

Vue.component('Empty', Empty)

import api from '@/api'

Vue.prototype.$api = Object.assign(api, {})
//点击放大图片
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'

Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
